package com.gqj.elec.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.elec.domain.ElecMaterialRepairdetail;
import com.gqj.elec.service.IElecMaterialRepairdetailService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 物资检修详情Controller
 *
 * @author lxq
 * @date 2023-12-17
 */
@RestController
@RequestMapping("/elec/elecMaterialRepairDetail")
public class ElecMaterialRepairdetailController extends BaseController
{
    @Autowired
    private IElecMaterialRepairdetailService elecMaterialRepairdetailService;

    /**
     * 查询物资检修详情列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialRepairDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElecMaterialRepairdetail elecMaterialRepairdetail)
    {
        startPage();
        List<ElecMaterialRepairdetail> list = elecMaterialRepairdetailService.selectElecMaterialRepairdetailList(elecMaterialRepairdetail);
        return getDataTable(list);
    }

    /**
     * 导出物资检修详情列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialRepairDetail:export')")
    @Log(title = "物资检修详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElecMaterialRepairdetail elecMaterialRepairdetail)
    {
        List<ElecMaterialRepairdetail> list = elecMaterialRepairdetailService.selectElecMaterialRepairdetailList(elecMaterialRepairdetail);
        ExcelUtil<ElecMaterialRepairdetail> util = new ExcelUtil<ElecMaterialRepairdetail>(ElecMaterialRepairdetail.class);
        util.exportExcel(response, list, "物资检修详情数据");
    }

    /**
     * 获取物资检修详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialRepairDetail:query')")
    @GetMapping(value = "/{repairdetailId}")
    public AjaxResult getInfo(@PathVariable("repairdetailId") Long repairdetailId)
    {
        return AjaxResult.success(elecMaterialRepairdetailService.selectElecMaterialRepairdetailByRepairdetailId(repairdetailId));
    }

    /**
     * 新增物资检修详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialRepairDetail:add')")
    @Log(title = "物资检修详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecMaterialRepairdetail elecMaterialRepairdetail)
    {
        return toAjax(elecMaterialRepairdetailService.insertElecMaterialRepairdetail(elecMaterialRepairdetail));
    }

    /**
     * 修改物资检修详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialRepairDetail:edit')")
    @Log(title = "物资检修详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecMaterialRepairdetail elecMaterialRepairdetail)
    {
        return toAjax(elecMaterialRepairdetailService.updateElecMaterialRepairdetail(elecMaterialRepairdetail));
    }

    /**
     * 删除物资检修详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialRepairDetail:remove')")
    @Log(title = "物资检修详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairdetailIds}")
    public AjaxResult remove(@PathVariable Long[] repairdetailIds)
    {
        return toAjax(elecMaterialRepairdetailService.deleteElecMaterialRepairdetailByRepairdetailIds(repairdetailIds));
    }

//    @PostMapping("/updateRepairTime/{repairdetailIds}")
//    public AjaxResult updateRepairTime(@PathVariable Long[] repairdetailIds)
//    {
//        return toAjax(elecMaterialRepairdetailService.updateRepairTime(repairdetailIds));
//    }

}
